package br.pucrio.inf.lac.konoha.hyuga.others.csv;

import java.util.List;

public class ClusteringStat {
    
    public static double sum(List<Double> dlist) {
        double sum = 0;
        for (double d : dlist) {
            sum += d;
        }
        
        return sum;
    }
    
    public static double average(List<Double> dlist) {
        return sum(dlist) / dlist.size();
    }
    
    public static double variance(List<Double> dlist) {
        double avg   = average(dlist);
        double total = 0;
        
        for (double d : dlist) {
            total += Math.pow(d - avg, 2);
        }
        
        return total / dlist.size();
    }
    
    public static double standardDeviation(List<Double> dlist) {
        return Math.sqrt(variance(dlist));
    }
    
}
